home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13289 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.4 KB  |  118 lines

  1. Path: mongol.sasknet.sk.ca!news@mongol.sasknet.sk.ca
  2. From: darren.dzikowski@dlcwest.com (Darren Dzikowski)
  3. Newsgroups: comp.lang.c++
  4. Subject: BC++ 4.5 Problems with Dialogs
  5. Date: 24 Mar 1996 19:04:18 GMT
  6. Organization: SaskNet News Distribution
  7. Message-ID: <4j46bi$65l@mongol.sasknet.sk.ca>
  8. NNTP-Posting-Host: sabre19.sasknet.sk.ca
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-Newsreader: WinVN 0.99.7
  12.  
  13. Hi there:
  14.  
  15. 1.  When I try to specify a dialog class with Borland's Resource Workshop,
  16. (ie. CLASS BorDLG_GRAY in a .RC file..(All I want to do is create a dialog 
  17. with a gray background)) the dialog box will display when I compile my 
  18. application and run it with Borland IDE running.  However, if I exit the IDE 
  19. and try to run my application, the dialog window will not open.  Is there a 
  20. header instruction I need to include to make this work properly?
  21.  
  22. 2.  Is there a quick and dirty way to change the background color of a dialog 
  23. window?  I would like it to be LT_GRAY...note problem 1...   I have a book on 
  24. this but it seemed pretty messy the way they explained it, which is something 
  25. like these excerpts(P.S.  I would like to know how to do it in both 16 and 32 
  26. bit Windows versions:)  Many thanks in advance!
  27.  
  28. #ifdef WIN32
  29.     case WM_CTLCOLORSTATIC:
  30.     case WM_CTLCOLORBTN:
  31.     case WM_CTLCOLOREDIT:
  32.       return HANDLE_WM_CTLCOLORSTATIC(hDlg, wParam, lParam, Shape_OnCtlColor); 
  33.     case WM_CTLCOLORDLG:
  34.       return HANDLE_WM_CTLCOLORDLG(hDlg, wParam, lParam, Shape_OnCtlColor);
  35.     #else
  36.     case WM_CTLCOLOR:
  37.       return HANDLE_WM_CTLCOLOR(hDlg, wParam, lParam, Shape_OnCtlColor);      
  38.  
  39.     #endif
  40.   }
  41.   return FALSE;
  42. }
  43.  
  44.  
  45. /////////////////////////////////////////////////////////
  46. // WM_CTLCOLOR 
  47. /////////////////////////////////////////////////////////
  48. #pragma argsused
  49. HBRUSH Size_OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type) 
  50. {
  51.   switch (type)
  52.   {
  53.     case CTLCOLOR_STATIC:
  54.       SetTextColor(hdc, RGB(255, 0, 0));
  55.       SetBkMode(hdc, TRANSPARENT); 
  56.       return GetStockBrush(BLACK_BRUSH); 
  57.  
  58.     case CTLCOLOR_DLG:
  59.       return GetStockBrush(BLACK_BRUSH);
  60.    }
  61.    return NULL;
  62. }
  63.  
  64.  
  65. /////////////////////////////////////////////////////////
  66. // WM_CTLCOLOR
  67. /////////////////////////////////////////////////////////
  68. #pragma argsused
  69. HBRUSH Shape_OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type) 
  70. {
  71.   switch(type)
  72.   {
  73.     case CTLCOLOR_STATIC:
  74.     case CTLCOLOR_EDIT:
  75.     case CTLCOLOR_BTN:
  76.       /* Set text to white and background to green */
  77.       SetTextColor(hdc, RGB(0, 127, 0));
  78.       SetBkMode(hdc, TRANSPARENT);
  79.       return GreenBrush;
  80.  
  81.     case CTLCOLOR_DLG:
  82.       return GreenBrush;
  83.   }
  84.   return NULL;
  85. }
  86.  
  87. //-------------------------------------------------
  88. // SizeBoxProc Dialog
  89. //-------------------------------------------------
  90. #pragma argsused
  91. BOOL CALLBACK SizeBoxProc(HWND hDlg, WORD Msg,
  92.                           WORD wParam, LONG lParam)
  93. {
  94.   TSIZEDATA SizeData;
  95.   void *lpSizeData;
  96.   char S[20];
  97.   int i;
  98.  
  99.   int Indexs[] = {2100, 2200, 2300, 2400, 2500, 2600};
  100.  
  101.   switch(Msg)
  102.   {
  103.     case WM_CLOSE:
  104.       DestroyWindow(hDlg);
  105.       hSizeBox = 0;
  106.       return TRUE;
  107.  
  108.     #ifdef WIN32
  109.     case WM_CTLCOLORSTATIC:
  110.       return HANDLE_WM_CTLCOLORSTATIC(hDlg, wParam, lParam, Size_OnCtlColor); 
  111.     case WM_CTLCOLORDLG:
  112.       return HANDLE_WM_CTLCOLORDLG(hDlg, wParam, lParam, Size_OnCtlColor);
  113.     #else
  114.     case WM_CTLCOLOR:
  115.       return HANDLE_WM_CTLCOLOR(hDlg, wParam, lParam, Size_OnCtlColor);
  116.     #endif
  117.  
  118.